local image = require("image")
local event = require("event")
local component = require("component")
local gpu = component.gpu

local test = {
	x = 5,
	y = 5,
	palette = {{
		char = "▝",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▀",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▘",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▐",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = " ",
		foreground = 0x000000,
		background = 0xffffff
	},{
		char = "▌",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▗",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▄",
		foreground = 0x000000,
		background = 0x00ffff
	},{
		char = "▖",
		foreground = 0x000000,
		background = 0x00ffff
	}},
	image = {}
}

gpu.setBackground(0x00ffff)
local x,y = gpu.getResolution()
gpu.fill(1,1,x,y," ")
for i = 1,test.x*test.y do
	local _,_,char = event.pull("key_down")
	char = char-string.byte('0')
	gpu.setForeground(test.palette[char].foreground)
	gpu.setBackground(test.palette[char].background)
	gpu.set((i-1)%test.x+1,(i-1)//test.x+1,test.palette[char].char)
	test.image[i] = char
end
image.ser("front.img",test)